<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


Route::group(['middleware' => ['client']], function () {
    Route::resource('buildings', 'BuildingsController')
        ->names(['index' => 'api.buildings.index'])
        ->except(['create', 'store', 'show', 'destroy', 'update', 'edit']);

    Route::resource('dorms', 'DormsController')
        ->names(['index' => 'api.dorms.index'])
        ->except(['create', 'store', 'show', 'destroy', 'update', 'edit']);

    Route::resource('dorm-meters', 'DormMetersController')
        ->names(['index' => 'api.dorm-meters.index'])
        ->except(['create', 'store', 'show', 'destroy', 'update', 'edit']);

    Route::resource('dorm-meter-records', 'DormMeterRecordsController')
        ->names([
            'index' => 'api.dorm-meter-records.index', //下载同步数据的接口
            'store' => 'api.dorm-meter-records.store',
            'update' => 'api.dorm-meter-records.update'
        ])
        ->except(['create', 'show', 'destroy', 'edit']);
    Route::resource('rating-categories', 'RatingCategoriesController')
        ->except(['create', 'show', 'destroy', 'edit']);
    Route::resource('dormitory-ratings', 'DormitoryRatingsController')
        ->except(['create', 'show', 'destroy', 'edit']);
    Route::resource('dorm-rating-mains', 'DormRatingMainsController');
    //h5 抄表记录
    Route::post('dorm-meter-recordings', 'DormMeterRecordsController@dormMeterRecordings');
});

//获取周期不需要登录
Route::resource('periods', 'PeriodsController')
    ->names(['index' => 'api.periods.index'])
    ->except(['create', 'store', 'show', 'destroy', 'update', 'edit']);

Route::get('online', function () {
    return response()->json(['online' => true]);
});
//提供给微信小程序查询员工费用信息的接口
Route::resource('staff-period-fees', 'StaffPeriodFeesController')
    ->names([
        'index' => 'api.staff-period-fees.index',
    ])
    ->except(['create', 'show', 'store', 'update', 'destroy', 'edit']);

//提供给钉钉程序查询员工身份信息的接口（未被使用）
Route::group(['prefix' => 'dingtalk'], function () {
    Route::get('corp-id', 'DingTalkController@getCorpId');
    Route::post('user-info', 'DingTalkController@getUserInfo');
});

//提供给钉钉H5页面查询宿舍信息的接口
Route::get('getDormsByBuilding', 'DormsController@getDormsByBuilding');
Route::get('getSubitemsByCategory', 'RatingSubItemsController@getSubitemsByCategory');
